package com.album.activity;

 
import java.io.Serializable;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
 

import com.album.R;
import com.album.activity.FolderImageList.MyCursorAdapter;
import com.album.activity.base.BaseActivity;
import com.album.activity.page.ImageListAdapter;
import com.album.activity.page.PhotoImageListAdapter;
import com.album.bean.ImageBean;
import com.album.common.Constants;
import com.album.common.Sharevariable;
import com.album.service.UploadImageService;
import com.album.utils.CommonUtil;
import com.album.utils.Config;
import com.album.utils.MyLog;

import dalvik.system.VMRuntime;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.GridView;
import android.widget.HorizontalScrollView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.SimpleAdapter;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.PopupWindow.OnDismissListener;
import android.widget.ViewFlipper;

public class ImageFolderListActivity extends BaseActivity implements View.OnClickListener {  
	
	private GridView gridView;
	public TextView countText;
	private BitmapFactory.Options options2;
	public static int maxCount = 12;
	public static int displayWidth, displayHeight;  
	private LinearLayout imageLayout; 
	private ImageListAdapter cursorAdapter;
	private Cursor imageCursor; 
	private boolean isGenerate = false;// 判断是不是跳转到生成界面，如果不是的话，不清空selectedBitmapList。
	private Activity context; 
	private String filePath;	// 当前文件夹目录

	private ImageButton btn_upload,btn_cancel;
	//当前选择位置
	public int select_position=-1;

	//上一次位置
	private Set<String> selectImagePaths = new LinkedHashSet<String>();	//选择上传的所有图片
	private int mPosition=0 ;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		context = this;
		setContentView(R.layout.folder_imagelist);
		filePath = getIntent().getExtras().getString("filePath");
		MyLog.debug(getClass(), "filePath:"+filePath);
		
		if (dialog == null) {
			dialog = ProgressDialog.show(this, "", "正在加载...", true); 
			dialog.setCancelable(true);
		}
		initView(); 
		setAdapter();
		// 跳转到图片选择界面
		gridView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				mPosition = select_position;	//上一次位置
				select_position = position;
				imageCursor.moveToPosition(position);
				if(mPosition != select_position){ 
					try {
//						imageCursor.moveToPosition(position);
						MyLog.debug(getClass(), "position:"+position);
						int nTemp = imageCursor.getColumnIndex("_data");
						String imagePath = imageCursor.getString(nTemp);
						MyLog.debug(getClass(), "imagePath:"+imagePath);
//						Bitmap tmpBitmap = BitmapFactory.decodeFile(imageCursor.getString(imageCursor.getColumnIndex("_data")), options2);
//						resizeBitmaps.add(tmpBitmap);
						selectImagePaths.add(imagePath);
						View views = gridView.getChildAt(position);
						views.findViewById(R.id.deleteImageView).setVisibility(View.VISIBLE);
//						tmpBitmap = null;
						options2 = null;	
					}catch (OutOfMemoryError e) {
						Toast.makeText(ImageFolderListActivity.this, getString(R.string.home_camear),Toast.LENGTH_SHORT).show();
						e.printStackTrace();
					} catch (IndexOutOfBoundsException e) { e.printStackTrace();
					} catch (Exception e) { e.printStackTrace();
					}
				}
			}
		});
	
	}
	
	
	private Thread removeThread = new Thread(){
		private void fun() {
			// TODO Auto-generated method stub
			try {
				clearBitmap();
				 
			}catch (IndexOutOfBoundsException e) {
				e.printStackTrace();
			}
		}
	};
	private Handler handler = new Handler() {
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case UPLOADING: 
				if(CommonUtil.isNetWorkActive(ImageFolderListActivity.this)){
	            	Intent intent = new Intent(Config.UPLOAD_IMAGE_ACTION);
	   				intent.setClass(ImageFolderListActivity.this, UploadImageService.class);
	   				intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
	            	Bundle bundle = new Bundle();
	            	bundle.putInt(Sharevariable.UPLOAD_TYPE, type);
	            	bundle.putInt(Sharevariable.UPLOAD_PUBLC, public_);
	            	bundle.putSerializable(Sharevariable.SELECT_IMAGE_PATH, (Serializable)selectImagePaths);
	            	intent.putExtras(bundle);
	   				startService(intent);
	   			}else{
	   				MessageDialog.showToast(ImageFolderListActivity.this, false, getResources().getString(R.string.int_error));
	   			}
				break;
			case 2:
				//Log.w("---------------", "不断执行"+msg.what);
//				scrollView.smoothScrollBy(1500, 0);
				//scrollView.scrollBy(150, 0);
				break;
			default:
			
				break;
			}
					
			}
	};
	private Runnable runnable = new Runnable() {

		@Override
		public void run() {
			// TODO Auto-generated method stub
			 
			Message msg = handler.obtainMessage();
			 msg.what = 2;
			 handler.sendMessage(msg);
		}  
		
	};
	
	protected void onLoding() {
		// 没选择图片时，重置和生成按钮不可以点击
//		btnGenerate.setEnabled(false);
		 
//		else {
//			btnReset.setEnabled(false);
//		}
		displayHeight = context.getWindowManager().getDefaultDisplay().getHeight();
		displayWidth = context.getWindowManager().getDefaultDisplay().getWidth();
		countText.setText(String.format(getString(R.string.error_title), --maxCount));
		
		gridView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				handler.post(runnable);
				if (maxCount > 0) {
					try {
						// 更改还可以选择的图片数目
						View selectedView = context.getLayoutInflater().inflate(R.layout.selected_imageview, null);
						LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(130, 110);
						layoutParams.setMargins(0, 0, 7, 0);
						selectedView.setLayoutParams(layoutParams);
						ImageView selectedImageView = (ImageView) selectedView.findViewById(R.id.selectImageView);
						ImageView deleteImageView = (ImageView) selectedView.findViewById(R.id.deleteImageView);
						options2 = new BitmapFactory.Options();
						options2.inJustDecodeBounds = true;
						imageCursor.moveToPosition(position);
						BitmapFactory.decodeFile(imageCursor.getString(imageCursor.getColumnIndex("_data")), options2);						
						Log.d("=============", "wwww:"+options2.outHeight+"=====hhhh:"+options2.outWidth);						
						if (options2.outHeight < 1000 && options2.outWidth < 1000) {
							options2.inSampleSize = 1;
						} else {
							options2.inSampleSize = computeInitialSampleSize(options2, -1, 500 * 500);
						}
						options2.inJustDecodeBounds = false;
						Bitmap tmpBitmap = BitmapFactory.decodeFile(imageCursor.getString(imageCursor
								.getColumnIndex("_data")), options2); 
						Log.i("width+height", "inSample:"+options2.inSampleSize+"width=" + tmpBitmap.getWidth() + "height=" + tmpBitmap.getHeight());
//						if (tmpBitmap.getWidth() > 480 && tmpBitmap.getHeight() > 480) {
//							Bitmap tmpResizeBitmap = tmpBitmap;
//							tmpBitmap = CommonUtil.createImage(tmpResizeBitmap, 480, 480, true);
//							if (tmpResizeBitmap != null && tmpResizeBitmap.isRecycled() == false) {
//								tmpResizeBitmap.recycle();
//								tmpResizeBitmap = null;
//							}
//						}
						Log.i("高与宽", "宽=" + tmpBitmap.getWidth() + "高=" + tmpBitmap.getHeight());	 
						selectedView.setTag(tmpBitmap);						
						
						view.setDrawingCacheEnabled(true);
						
//						bitmap = Bitmap.createScaledBitmap(view.getDrawingCache(), 125, 105, true);						
						selectedImageView.setImageBitmap(tmpBitmap);
						selectedImageView.setTag(tmpBitmap);
						deleteImageView.setTag(selectedView);
//						deleteImageView.setOnTouchListener(imageListener); 
						tmpBitmap = null;
						options2 = null;						
					} catch (OutOfMemoryError e) {
						Toast.makeText(context, getString(R.string.home_camear),Toast.LENGTH_SHORT).show();
						e.printStackTrace();
					} catch (IndexOutOfBoundsException e) {
						e.printStackTrace();
					} catch (Exception e) {
						e.printStackTrace();
					}
				} else {
					Toast.makeText(context, getString(R.string.home_cancel), Toast.LENGTH_SHORT).show();
				}
			}
		});
		
		
		// 重置按钮，删除已选择的图片
//		btnReset.setOnClickListener(new OnClickListener() {
//			@Override
//			public void onClick(View v) {
//				btnGenerate.setEnabled(false);
//				btnReset.setEnabled(false);
//				if (resizeBitmaps != null) {
//					for (int i = 0, l = resizeBitmaps.size(); i < l; i++) {
//						if (resizeBitmaps.get(i) != null && !resizeBitmaps.get(i).isRecycled()) {
//							resizeBitmaps.get(i).recycle();
//						}
//					}
//					resizeBitmaps.clear();
//				}
//				imageLayout.removeAllViews();
//				if (selectedBitmapList != null && selectedBitmapList.size() > 0) {
//					for (int i = 0, l = selectedBitmapList.size(); i < l; i++) {
//						if (selectedBitmapList.get(i) != null && !selectedBitmapList.get(i).isRecycled()) {
//							selectedBitmapList.get(i).recycle();
//						}
//					}
//					selectedBitmapList.clear();
//				}
//				maxCount = 12;
//				countText.setText(String.format(getString(R.string.home_refresh), maxCount));
//				clearBitmap();
//			}
//		});
//		// 返回选择相册界面
//		btnBack.setOnClickListener(new OnClickListener() {
//			@Override
//			public void onClick(View v) {
//				backEvent(ImageFolderListActivity.class, null);
//			}
//		});
//		// 跳转到图片生成界面
//		btnGenerate.setOnClickListener(new OnClickListener() {
//			@Override
//			public void onClick(View v) {
//				if (resizeBitmaps != null) {
//					if (resizeBitmaps.size() >= 2) {
//						maxCount = 12;
//						// 把选择的图片处理一下
//						imageLayout.removeAllViews();
//						imageLayout.setVisibility(View.GONE);
//						// 把已经存储的已选择图片的缩略图回收
//						if (selectedBitmapList != null && selectedBitmapList.size() > 0) {
//							for (int i = 0, l = selectedBitmapList.size(); i < l; i++) {
//								if (selectedBitmapList.get(i) != null && !selectedBitmapList.get(i).isRecycled()) {
//									selectedBitmapList.get(i).recycle();
//								}
//							}
//							selectedBitmapList.clear();
//						}
//						isGenerate = true;
//						backEvent(HomeActivity.class, filePath);
//					} else if (resizeBitmaps.size() == 1) {
//						Toast.makeText(context, "image_min", Toast.LENGTH_SHORT)
//								.show();
//					}
//				}
//			}
//		});
//		System.gc(); 
	}
	 
	// 删除图片的点击事件
//	private OnTouchListener imageListener = new OnTouchListener() {
//		@Override
//		public boolean onTouch(View v, MotionEvent event) {
//			View tempView = (View) v.getTag();
//			// 删除已经添加到图片
//			resizeBitmaps.remove(tempView.getTag());
//			imageLayout.removeView(tempView);
//			selectedBitmapList.remove(tempView.findViewById(R.id.selectImageView).getTag());
//			maxCount = 12 - imageLayout.getChildCount();
//			countText.setText(String.format(getString(R.string.home_wangpang), maxCount));
//			return true;
//		}
//	};

	// 回收图片
	private void clearBitmap() {
//		if (resizeBitmaps != null && resizeBitmaps.size() > 0) {
//			for (int i = 0, l = resizeBitmaps.size(); i < l; i++) {
//				if (resizeBitmaps.get(i) != null && !resizeBitmaps.get(i).isRecycled()) {
//					resizeBitmaps.get(i).recycle();
//				}
//			}
//			resizeBitmaps.clear();
//			resizeBitmaps=null;
//		}
	}

	// 所有离开当前页面事件的处理
	private void backEvent(Class<?> cls, String extraString) {
		VMRuntime.getRuntime().gcSoftReferences();
		Intent intent = new Intent(context, cls);
		if (extraString != null) {
			intent.putExtra("filePath", filePath);
		}
		context.startActivity(intent);
		if (gridView != null) {
			gridView.setVisibility(View.GONE);
			gridView = null;
		}
		if (imageCursor != null && !imageCursor.isClosed()) {
			imageCursor.close();
		}
		// 如果是跳转到图片生成界面，清空selectedBitmapList。
		if (isGenerate) {
			 
		}
//		finish();
	}
 
	// 返回键跳转到模式选择界面
//	@Override
//	public boolean onKeyDown(int keyCode, KeyEvent event) {
//		if (keyCode == KeyEvent.KEYCODE_BACK) {
//			backEvent(ImageFolderList.class, null);
//		}
//		return super.onKeyDown(keyCode, event);
//	}

	private ProgressDialog dialog=null;

	private void setAdapter() {
		if (imageCursor != null && !imageCursor.isClosed()) {
			imageCursor.close();
		}
		imageCursor = getCursor();
		if (imageCursor != null && imageCursor.getCount() > 0) {
			
			List<Bitmap> dataSource =new ArrayList<Bitmap>();
			
			BitmapFactory.Options options = new BitmapFactory.Options();
			options.inSampleSize = 100;
			
			cursorAdapter = new ImageListAdapter(context, imageCursor);
			gridView.setAdapter(cursorAdapter);

//			for(imageCursor.moveToFirst(); !imageCursor.isAfterLast();imageCursor.moveToNext()) {
//				int id = imageCursor.getInt(imageCursor.getColumnIndex("_ID"));
//				Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(context.getContentResolver(), id,
//						MediaStore.Images.Thumbnails.MICRO_KIND, options);
//				cursorAdapter.setNotifyDataSetChanged(bitmap);
//			}
//			
			if (dialog != null || dialog.isShowing())
				dialog.dismiss();
		}
	}

	private int computeInitialSampleSize(BitmapFactory.Options options, int minSideLength, int maxNumOfPixels) {
		double w = options.outWidth;
		double h = options.outHeight;
		int lowerBound = (maxNumOfPixels == -1) ? 1 : (int) Math.ceil(Math.sqrt(w * h / maxNumOfPixels));
		int upperBound = (minSideLength == -1) ? 128 : (int) Math.min(Math.floor(w / minSideLength), Math.floor(h
				/ minSideLength));
		if (upperBound < lowerBound) {
			return lowerBound;
		}
		if ((maxNumOfPixels == -1) && (minSideLength == -1)) {
			return 1;
		} else if (minSideLength == -1) {
			return lowerBound;
		} else {
			return upperBound;
		}
	}

	private Cursor getCursor() {
		Uri originalUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
		ContentResolver cr = context.getContentResolver();
		// "_id DESC"的作用是使新拍摄的照片可以在前面显示
		imageCursor = cr.query(originalUri, null, "_data like '%" + filePath + "%'", null, "_id DESC");
		String[] strings = imageCursor.getColumnNames();
//		for (int i = 0; i < strings.length; i++) {
//			MyLog.debug(getClass(), "YYYYYYYYYYYYYYYYYYYYY:"+strings[i]);
//		}
		return imageCursor;
	} 
	
	private void initView(){
		gridView = (GridView)findViewById(R.id.gridView);
		btn_upload = (ImageButton)findViewById(R.id.btn_upload);
		btn_cancel = (ImageButton)findViewById(R.id.btn_cancel);
		btn_cancel.setOnClickListener(this);
		btn_upload.setOnClickListener(this); 
	}
	 
	
	private void backNitiveManagerActivity(){
//		Intent intent = new Intent();
//		intent.setClass(ImageFolderListActivity.this, nitiveManagerActivity.class);
//		startActivity(intent);
		setResult(RESULT_OK);
		this.finish();
	}
	 
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
				backNitiveManagerActivity(); 
				return true;
		}
		return super.onKeyDown(keyCode, event);
	} 
	 
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		new Thread(){
			@Override
			public void run() {
				// TODO Auto-generated method stub
				if(cursorAdapter!=null)
					cursorAdapter.clearDataSource();
			}
		}.start();
		super.onDestroy();
		
	} 
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		Intent intent = new Intent();
		switch (v.getId()) {
		case R.id.btn_upload: 
//			CreatDialog();
//			initPopupWindow();
			showToastDialog();
			break;
		case R.id.btn_cancel:
			backNitiveManagerActivity();
			break;	
		default:
			break;
		}
	}
	
    int mSingleChoiceID = -1;
    
    final String[] mItems = {"公开的照片","密码照片","分享的照片"};
    
	public void CreatDialog() {
		AlertDialog.Builder builder = new AlertDialog.Builder(this);	
		builder.setIcon(android.R.drawable.ic_menu_upload);
        builder.setTitle(getResources().getString(R.string.label_select_upload_type));
        builder.setSingleChoiceItems(mItems, 0, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                    mSingleChoiceID = whichButton;
            }
        });
        builder.setPositiveButton(getResources().getString(R.string.label_ok), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
               MyLog.debug(getClass(), "mSingleChoiceID:"+mSingleChoiceID); 
               int selectSize= selectImagePaths.size();
				if(selectSize>0){
		               if(handler!=null)
		            	   handler.sendEmptyMessage(UPLOADING);
				}else{
					MessageDialog.showToast(ImageFolderListActivity.this, false, getResources().getString(R.string.label_select_upload_image));
				}
            }
        });
        builder.setNegativeButton(getResources().getString(R.string.label_cancel), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {

            }
        });
        builder.create().show();
	}
	
	
	int type = 4;
	int public_ = 0;
	 public void DisplayToast(String str)  
	    {  
	        Toast toast=Toast.makeText(this, str, Toast.LENGTH_LONG);  
	        toast.setGravity(Gravity.TOP,0,220);  
	        toast.show();  
	    } 
	 
	private void showToastDialog(){ 
		LayoutInflater inflater = getLayoutInflater();
		View popview = inflater.inflate(R.layout.upload_image,null);
		RadioGroup radiogroup1=(RadioGroup)popview.findViewById(R.id.radiogroup1);  
		RadioGroup radiogroup2=(RadioGroup)popview.findViewById(R.id.radiogroup2);  
		radiogroup1.setOnCheckedChangeListener(new OnCheckedChangeListener() { 
				@Override
				public void onCheckedChanged(RadioGroup group, int checkedId) {
					// TODO Auto-generated method stub
					switch (checkedId) {
					case R.id.radiobutton1:
						type=5;
						break; 
					case R.id.radiobutton2:
						type=6;
						break;
					case R.id.radiobutton3:
						type=7;
						break;
					case R.id.radiobutton4:
						type=4;
						break;
					default:
						break;
					}
				}
		});
		radiogroup2.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				// TODO Auto-generated method stub
				switch (checkedId) {
				case R.id.radio_gongkai:
					public_=0;
					break;
				case R.id.radio_pwd:
					public_=2;
					break;
				case R.id.radio_share:
					public_=1;
					break;
				default:
					break;
				}
			}
		});
		
		final AlertDialog alert = new AlertDialog.Builder(this).create(); 
		alert.show(); 
		alert.getWindow().setLayout(
				android.view.WindowManager.LayoutParams.FILL_PARENT, 
				android.view.WindowManager.LayoutParams.WRAP_CONTENT); 
		alert.getWindow().setContentView(popview); 
		((Button)popview.findViewById(R.id.btn_ok)).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View paramView) {
				// TODO Auto-generated method stub
				 int selectSize= selectImagePaths.size();
				  if(selectSize>0){
			               if(handler!=null)
			            	   handler.sendEmptyMessage(UPLOADING);
					}else{
						MessageDialog.showToast(ImageFolderListActivity.this, false, getResources().getString(R.string.label_select_upload_image));
					}
					alert.cancel();
			}
		});
		((Button)popview.findViewById(R.id.btn_cancel)).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View paramView) {
				// TODO Auto-generated method stub
				alert.cancel();
			}
		});
	}
	 
	private void initPopupWindow(){
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
	    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View popview = inflater.inflate(R.layout.upload_image,null,false); 

		RadioGroup radiogroup=(RadioGroup)popview.findViewById(R.id.radiogroup1);  
        RadioButton radio1=(RadioButton)popview.findViewById(R.id.radiobutton1);  
        RadioButton radio2=(RadioButton)popview.findViewById(R.id.radiobutton2);  
        RadioButton radio3=(RadioButton)popview.findViewById(R.id.radiobutton3);  
        RadioButton radio4=(RadioButton)popview.findViewById(R.id.radiobutton4); 
        
        radiogroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				// TODO Auto-generated method stub
				 DisplayToast("正确答案："+checkedId+"，恭喜你，回答正确！"); 
			}
		});
        
		final PopupWindow pop=new PopupWindow(popview,Constants.window_width-100,Constants.window_heigt-500,true);
//		pop.setBackgroundDrawable(context.getResources().getDrawable(R.drawable));
		pop.setOutsideTouchable(true);
		pop.setFocusable(true);

		pop.setOnDismissListener(new OnDismissListener() {
			@Override
			public void onDismiss() {
				// TODO Auto-generated method stub
				if(pop.isShowing())	pop.dismiss();
			}
		});
		//if(pop.isShowing())	pop.dismiss();
		pop.showAtLocation(popview, Gravity.CENTER, 0, 0);   

	}
	private final int UPLOADING=1;
}
